const Validate = require('./common/validate')
const validateParams = require('./common/validateparams')
const Login = require('./module/login/index')
const Admin = require('./module/admin/index')

const User = require('./module/user/user')

const Adver = require('./module/media/adver')
const Banner = require('./module/media/banner')
const Category = require('./module/media/category')
const Notice = require('./module/media/notice')

const Goods = require('./module/goods/goods')
const Order = require('./module/order/order')

const PayWater = require('./module/fund/pay-water')
const Coupon = require('./module/action/coupon')

const Qiniu = require('./common/qiniu')

const defaultObejct = {
	httpInfo: {},
	_before: function() { // 通用预处理器
		this.httpInfo = this.getHttpInfo()
		const validate = new Validate(this.getHttpInfo())
		validate.validateMethod()
		if (this.httpInfo.path != "/login") {
			validate.validateToken(this.httpInfo)
		}
	}
}

module.exports = {
	...defaultObejct,
	...Qiniu,
	...Login,
	...Admin,
	...User,
	...Adver,
	...Banner,
	...Category,
	...Notice,
	...Goods,
	...Order,
	payWaterList() {
		return new PayWater(this.httpInfo).list()
	},
	couponList() {
		return new Coupon(this.httpInfo).list()
	},
	couponAdd() {
		return new Coupon(this.httpInfo).add()
	},
	test() {
		// new validateParams({
		// 	username: "小明"
		// }, "username:required,password:required")
		// return new PayWater({
		// 	Method:"GET"
		// }).list()
	}
}
// module.exports = {
// 	test() {
// 		return {
// 			name: "test"
// 		}
// 	}
// }
